const tags = {
    name: "movies",
    description: "电影管理模块",
};

const schemas = {
    // 获取当前页面的条件的数据结构
    ArrayOfMovies: {
        properties: {
            total: {
                type: "number",
                description: "总数",
            },
            maxPage: {
                type: "number",
                description: "总页数",

            },
            rows: {
                type: "array",
                description: "电影当页数据",
                items: {
                    $ref: "#/components/schemas/movies"
                }
            }
        }
    },
    // 每条电影数据的结构
    movies: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            cname: {
                description: "电影名",
                type: "string",
            },
            ename: {
                description: "电影英文名",
                type: "string",
            },
            type: {
                description: "电影的类型",
                type: "string",
            },
            area: {
                description: "电影首映地区",
                type: "string",
            },
            upDate: {
                description: "电影大陆上映时间",
                type: "string",

            },
            score: {
                description: "电影评分",
                type: "number",

            },
            time: {
                description: "电影时长",
                type: "number",

            },
            count: {
                description: "电影票房",
                type: "string",

            },
            intro: {
                description: "剧情简介",
                type: "string",

            },
            isClassic: {
                description: "是否是经典",
                type: "boolean",

            },
            director: {
                description: "导演名字",
                type: "string",

            },
            actor: {
                description: "演员名字",
                type: "string",

            },
            images: {
                description: "剧集图片",
                type: "array",
               }
        }
    },
    // 新增学生结构
    addMovies: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            cname: {
                description: "电影名",
                type: "string",
            },
            ename: {
                description: "电影英文名",
                type: "string",
            },
            type: {
                description: "电影的类型",
                type: "string",
            },
            area: {
                description: "电影首映地区",
                type: "string",
            },
            upDate: {
                description: "电影大陆上映时间",
                type: "string",

            },
            score: {
                description: "电影评分",
                type: "number",

            },
            time: {
                description: "电影时长",
                type: "number",

            },
            count: {
                description: "电影票房",
                type: "string",

            },
            intro: {
                description: "剧情简介",
                type: "string",

            },
            isClassic: {
                description: "是否是经典",
                type: "boolean",

            },
            director: {
                description: "导演名字",
                type: "string",

            },
            actor: {
                description: "演员名字",
                type: "string",

            },
            images: {
                description: "剧集图片",
                type: "array",
               }
        }
    },
    // 新增学生返回值结构
    addReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },
    },
    // 删除学生结构
    removeMovies: {
        properties: {
            _id: {
                type: "string",
                description: "id值",
            }
        }
    },
    // 删除学生返回值结构
    removeReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },
    },
    // 修改学生结构
    changeMovies: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            cname: {
                description: "电影名",
                type: "string",
            },
            ename: {
                description: "电影英文名",
                type: "string",
            },
            type: {
                description: "电影的类型",
                type: "string",
            },
            area: {
                description: "电影首映地区",
                type: "string",
            },
            upDate: {
                description: "电影大陆上映时间",
                type: "string",

            },
            score: {
                description: "电影评分",
                type: "number",

            },
            time: {
                description: "电影时长",
                type: "number",

            },
            count: {
                description: "电影票房",
                type: "string",

            },
            intro: {
                description: "剧情简介",
                type: "string",

            },
            isClassic: {
                description: "是否是经典",
                type: "boolean",

            },
            director: {
                description: "导演名字",
                type: "string",

            },
            actor: {
                description: "演员名字",
                type: "string",

            },
            
        }
    },
    // 删除学生返回值结构
    changeReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },

    }

};

const paths = {
    "/movies": {
        get: {
            tags: ["movies"],
            summary: "获取电影当页数据信息,渲染到电影列表",
            description: "获取当页的电影数据", // 具体描述
            consumes: ["application/json"],
            // parameters 请求参数
            parameters: [
                {
                    name: "curPage",
                    in: "query",    //get类型的参数在query中获取
                    schema: {
                        type: "integer",   //integer 整数
                        default: 1,
                    },
                    required: true,  //必填
                    description: "当前⻚码",
                },
                {
                    name: "eachPage",
                    in: "query",
                    schema: {
                        type: "integer",
                        default: 1,
                    },
                    required: true,
                    description: "每⻚显示条数",
                },
            ],
            responses: {
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/ArrayOfMovies",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/movies/add": {
        post: {
            tags: ["movies"], //属于哪一个功能模块
            summary: "新增电影",
            // 具体描述
            description: "这是一个新增电影功能，需传入电影相对应的参数",
            consumes: ["application/json"], //请求的数据类型 JSON
            requestBody: {    //请求参数
                required: true, //必填
                content: {  //内容(具体参数)
                    "application/json": {
                        schema: {//参数的结构
                            $ref: "#/components/schemas/addMovies",
                        },
                        // example 例子
                        example: {
                            "_id": "614ee6aedc364c19d8bee169",
                            "cname": "天堂之日",
                            "ename": "Paul Young",
                            "type": "恐怖",
                            "area": "中国香港",
                            "poster": "http://dummyimage.com/240x400",
                            "time": 178,
                            "upDate": "2021-08-05",
                            "score": 6.9,
                            "count": "24.5",
                            "intro": "SDGcBgmI[A^tz&u1Au[GNMy)s^LLA&c^@%u5MRnUXj#EhA&^5%)mN8INY9gjmO9NCXz5e#6jW[4zRc)%xYI2U$ZjA^uSYX9tDiS&hVzACmBZnPTmiV9%E7j4)BZP78AU!yNpQ&mxuPl3Iu#81kelUAobvnQba!7J)bCfNq7*#Pc3*)pg86yiD2^ZV2hw1Czx8R4N)MUDbqmqU#fmjUtEo1(Vj9V&U(OK5jhre(G8i@mPA(P1DO*#3F%WRNJ8gRG&NEXo",
                            "isClassic": false,
                            "director": "Donald White",
                            "actor": "Mark Davis",
                          },
                    },
                },
            },
            // 响应
            responses: {
                // http状态码
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/addReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/movies/remove": {
        post: {
            tags: ["movies"], //属于哪一个功能模块
            summary: "删除电影",
            // 具体描述
            description: "这是一个删除电影功能，需传入电影相对应的参数",
            consumes: ["application/json"], //请求的数据类型 JSON
            requestBody: {    //请求参数
                required: true, //必填
                content: {  //内容(具体参数)
                    "application/json": {
                        schema: {//参数的结构
                            $ref: "#/components/schemas/removeMovies",
                        },
                        // example 例子
                        example: {
                            _id: "614d673f0037f4201c411b1f",
                        },
                    },
                },
            },
            // 响应
            responses: {
                // http状态码
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/removeReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/movies/change": {
        put: {
            tags: ["movies"], //属于哪一个功能模块
            summary: "修改电影",
            // 具体描述
            description: "这是一个修改电影功能，需传入电影相对应的参数",
            consumes: ["application/json"], //请求的数据类型 JSON
            requestBody: {    //请求参数
                required: true, //必填
                content: {  //内容(具体参数)
                    "application/json": {
                        schema: {//参数的结构
                            $ref: "#/components/schemas/changeMovies",
                        },
                        // example 例子
                        example: {
                            "_id": "614ee6aedc364c19d8bee169",
                            "cname": "天堂之日",
                            "ename": "Paul Young",
                            "type": "恐怖",
                            "area": "中国香港",
                            "poster": "http://dummyimage.com/240x400",
                            "time": 178,
                            "upDate": "2021-08-05",
                            "score": 6.9,
                            "count": "24.5",
                            "intro": "SDGcBgmI[A^tz&u1Au[GNMy)s^LLA&c^@%u5MRnUXj#EhA&^5%)mN8INY9gjmO9NCXz5e#6jW[4zRc)%xYI2U$ZjA^uSYX9tDiS&hVzACmBZnPTmiV9%E7j4)BZP78AU!yNpQ&mxuPl3Iu#81kelUAobvnQba!7J)bCfNq7*#Pc3*)pg86yiD2^ZV2hw1Czx8R4N)MUDbqmqU#fmjUtEo1(Vj9V&U(OK5jhre(G8i@mPA(P1DO*#3F%WRNJ8gRG&NEXo",
                            "isClassic": false,
                            "director": "Donald White",
                            "actor": "Mark Davis",
                          },
                    },
                },
            },
            // 响应
            responses: {
                // http状态码
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/changeReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    }

}

module.exports = { tags, schemas, paths };